package com.mlh.linkedlist;

import java.util.List;

//定义链表节点
public class ListNode {
    int val;
    ListNode next;

    public ListNode(){}

    public ListNode(int val) {
        this.val=val;
    }
    public ListNode(int val,ListNode next){
        this.val=val;
        this.next=next;
    }

    public static ListNode createLinkedList(int[]val){
        ListNode head=new ListNode(val[0]);
        ListNode temp=head;
        for (int i = 1; i < val.length; i++) {
            temp.next=new ListNode(val[i]);
            temp=temp.next;
        }
        return head;
    }

    public static void show(ListNode head){
        while (head.next!=null){
            System.out.print(head.val+"->");
            head=head.next;
        }
        System.out.print(head.val+"    ");
    }
}
